package com.mp.approvalreq.util;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Calendar;

/**
 * @author Liquid
 * @类名： TimeUtils
 * @描述：
 * @date 2019/4/13
 */
public class TimeUtils {


    /**
     * @param
     * @return Date当前日期
     * @描述： 获取当前格式化后的的时间
     * @author Liquid
     * @date 2018/12/26
     */
    private static long getCurrentTimeMills() {
        return Calendar.getInstance().getTimeInMillis();
    }

    public static int compareWithCurrentTimeWithoutTime(long time){

        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
        LocalDateTime curLocalDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(TimeUtils.getCurrentTimeMills()), ZoneId.systemDefault());
        int compareYear = Integer.compare(localDateTime.getYear(), curLocalDateTime.getYear());

        if (compareYear!=0){
            return compareYear;
        }else{
            int compareMonth = Integer.compare(localDateTime.getMonthValue(), curLocalDateTime.getMonthValue());
            if (compareMonth!=0){
                return compareMonth;
            }else {
                return Integer.compare(localDateTime.getDayOfMonth(), curLocalDateTime.getDayOfMonth());
            }
        }


    }

}
